package com.app.dao;

import com.app.entity.User;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class UserDao
{
    private SessionFactory sessionFactory;

    @Resource
    public void setSessionFactory(SessionFactory sessionFactory)
    {
        this.sessionFactory = sessionFactory;
    }

    public User getUser()
    {
        User user = new User();

        user.setId(100);
        user.setName("dao");
        user.setAddress("dao");

        return user;
    }

    public void createUser()
    {
        User user = new User();

        user.setName("abc");
        user.setAddress("cdef");

        Session session = sessionFactory.getCurrentSession();
        session.save(user);
    }
}
